<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
    <#include "/end/include/head.ftl"/>
</head>
<body>
    <div>
        <#--搜索框-->
        <blockquote class="layui-elem-quote">
            <form class="layui-form">
                <#--添加菜单-->
                    <div class="layui-inline">
                            <@shiro.hasPermission name="system.user.add">
                                <button class="layui-btn addBtn" id="addBtn" data-url="${basePath}/user/toAdd.do"
                                        data-title="新增用户" data-width="800px" data-height="500px">新增用户
                                </button>
                            </@shiro.hasPermission>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">页码</label>
                        <div class="layui-input-block" style="width: 80px;">
                        <@dictSelect id="pageSize" name="pageSize" code="pageSize" showSelect="false" layfilter="pageChange" value="${pageSize}"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" id="username" placeholder="请输入用户名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                            <button class="layui-btn" id="userSearchBtn" lay-filter="userSearchBtn">搜索</button>
                    </div>
            </form>
        </blockquote>
            <fieldset class="layui-elem-field">
                <legend>数据列表</legend>
                <div class="layui-field-box layui-form">
                    <table class="layui-table admin-table">
                        <thead>
                        <tr>
                            <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary"></th>
                            <th>用户名</th>
                            <th>真实姓名</th>
                            <th>手机号码</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list list as info>
                        <tr>
                            <td></td>
                            <td>${info.username!}</td>
                            <td>${info.realName!}</td>
                            <td>${info.mobilePhone!}</td>
                            <td>
                                <@shiro.hasPermission name="system.user.edit">  <a href="javascript:void(0)" class="layui-btn layui-btn-mini editBtn" data-url="${basePath}/user/toEdit.do?id=${info.id}" data-title="修改用户" data-width="800px" data-height="500px">编辑</a></@shiro.hasPermission>
                                <@shiro.hasPermission name="system.user.detail">  <a class="layui-btn layui-btn-normal layui-btn-mini detailBtn" data-url="${basePath}/user/toDetail.do?id=${info.id}" data-title="用户详情" data-width="800px" data-height="500px">详情</a></@shiro.hasPermission>
                                <@shiro.hasPermission name="system.user.delete">  <a class="layui-btn layui-btn-danger layui-btn-mini deleteBtn" data-url="${basePath}/user/doDelete.do?id=${info.id}" data-title="删除用户" data-width="800px" data-height="500px">删除</a></@shiro.hasPermission>
                                <@shiro.hasPermission name="system.user.password"> <a class="layui-btn layui-btn-warm layui-btn-mini editBtn" data-url="${basePath}/user/toPassword.do?id=${info.id}" data-title="修改密码" data-width="800px" data-height="500px">修改密码</a></@shiro.hasPermission>
                            </td>
                        </tr>
                        </#list>
                        </tbody>
                    </table>
                </div>
            </fieldset>
            <div class="admin-table-page">
                <div id="paged" class="page">
                </div>
            </div>
</body>
<script>
    var pages = ${pages!0};
    layui.use(['laypage', 'layer','form'], function() {
        var laypage = layui.laypage, layer = layui.layer;
        var form = layui.form();
        form.render();
        laypage({
            cont: 'paged',
            pages: pages, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
            curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
                var page = location.search.match(/pageNo=(\d+)/);
                return page ? page[1] : 1;
            }(),
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    location.href = '?pageSize=1&pageNo='+e.curr;
                }
            }
        });
        form.on('submit(userSearchBtn)', function(data){
            layer.msg(JSON.stringify(data.field));
            var page = location.search.match(/pageNo=(\d+)/);
            page = page ? page[1] : 1;
            var pageSize = $("#pageSize").val();
            var username = $("#username").val();
            location.href = '?pageSize=' + pageSize +'&pageNo='+page + '&username=' + username;
            return false;
        });
    });

</script>